/*
 * main.c
 *
 *  Created on: Apr 18, 2009
 *      Author: thaison
 */

#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <iostream.h>

#include "ants.h"
#include "utilities.h"
#include "InOut.h"
#include "TSP.h"
#include "timer.h"
#include "ls.h"
#include "acotsp.h"
#include "anneal.h"
#include "GA.h"
#include "hybrid.h"
#include "solution.h"

/* --- main program ------------------------------------------------------ */

int main(int argc, char *argv[]) {
	/*
	 FUNCTION:       main control for running the ACO algorithms
	 INPUT:          none
	 OUTPUT:         none
	 (SIDE)EFFECTS:  none
	 COMMENTS:       this function controls the run of "max_tries" independent trials

	 */
	init_program(argc, argv);

	if (algorithm_flag == 2) { /* SA algorithm has been chosen */
		SA_main(argc, argv);
	} else if (algorithm_flag == 4) { /* GA algorithm has been chosen */
		GA_main(argc, argv);
	} else if (algorithm_flag == 5) { /* PGA algorithm has been chosen */
		PGA_main(argc, argv);
	} else if (algorithm_flag == 3) { /* PSA algorithm has been chosen */
		PSA_main(argc, argv);
	} else if (algorithm_flag == 6) { /* Hybrid algorithm has been chosen */
		Hybrid_main(argc, argv);
	} else if (algorithm_flag == 1) { /* Parallel ACO algorithm has been chosen */
		//n_ants = n_ants / 2;
		PACO_main(argc, argv);
	} else if (algorithm_flag == 0) { /* ACO algorithm has been chosen */
		ACO_main(argc, argv);
	}
	if (is_opened == 0) {
		cout << best_solution.cost << "\n";
		cout << elapsed_time() << "\n";
		for (int i = 0; i < n; i++) {
			cout << best_solution.tour[i] << " ";
		}
	} else {
		out_stream << best_solution.cost << "\n";
		out_stream << elapsed_time() << "\n";
		for (int i = 0; i < n; i++) {
			out_stream << best_solution.tour[i] << " ";
		}
	}
	return (0);
}
